/* 设置按钮样式移动到 index.css 中管理，避免冲突 */

/* 工具提示样式 */
.tooltip {
  position: absolute;
  background: rgba(0,0,0,0.8);
  color: white;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
  z-index: 10001;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.2s ease;
  pointer-events: none;
  backdrop-filter: blur(10px);
}

.tooltip.show {
  opacity: 1;
  transform: translateY(0);
}

.tooltip::after {
  content: '';
  position: absolute;
  top: -5px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;  border-bottom: 5px solid rgba(0,0,0,0.8);
}

/* 模态框样式 */
.model {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.6);
  backdrop-filter: blur(5px);
  animation: modelFadeIn 0.3s ease-out;
}

@keyframes modelFadeIn {
  from {
    opacity: 0;
    backdrop-filter: blur(0px);
  }
  to {
    opacity: 1;
    backdrop-filter: blur(5px);
  }
}

.model-content {
  background: linear-gradient(135deg, #f0f8ff 0%, #e3f2fd 100%);
  margin: 8% auto;
  padding: 0;
  border-radius: 16px;
  width: 90%;
  max-width: 480px;
  max-height: 85vh;
  box-shadow: 0 20px 60px rgba(25, 118, 210, 0.3), 0 8px 25px rgba(25, 118, 210, 0.15);
  border: 1px solid rgba(144, 202, 249, 0.3);
  animation: modelSlideIn 0.3s ease-out;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

@keyframes modelSlideIn {
  from {
    transform: translateY(-50px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.model-show .model-content {
  animation: modelSlideIn 0.3s ease-out;
}

.model-hide {
  animation: modelFadeOut 0.3s ease-in;
}

.model-hide .model-content {
  animation: modelSlideOut 0.3s ease-in;
}

@keyframes modelFadeOut {
  from {
    opacity: 1;
    backdrop-filter: blur(5px);
  }
  to {
    opacity: 0;
    backdrop-filter: blur(0px);
  }
}

@keyframes modelSlideOut {
  from {
    transform: translateY(0);
    opacity: 1;
  }
  to {
    transform: translateY(-50px);
    opacity: 0;
  }
}

.model-header {
  background: linear-gradient(135deg, #1976d2 0%, #1e88e5 50%, #42a5f5 100%);
  color: white;
  padding: 10px 25px 10px;
  border-radius: 16px 16px 0 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 10px rgba(25, 118, 210, 0.3);
}

.model-header h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.model-body {
  padding: 15px 25px 25px;
  overflow-y: auto;
  flex: 1;
  max-height: calc(85vh - 80px);
}

.close {
  color: rgba(255,255,255,0.8);
  font-size: 24px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s ease;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.1);
}

.close:hover {
  color: white;
  background: rgba(255,255,255,0.2);
  transform: rotate(90deg);
}

.settings-group {
  margin: 10px 0;
  padding: 18px;
  background: linear-gradient(135deg, #f0f8ff 0%, #ffffff 100%);
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(25, 118, 210, 0.08);
  border: 1px solid rgba(144, 202, 249, 0.2);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.settings-group:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(25, 118, 210, 0.15);
}

.settings-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: #1565c0;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.model-select-container {
  display: flex;
  gap: 10px;
  align-items: center;
}

#model-select {
  width: calc(100% - 120px);
  min-width: calc(100% - 120px);
  padding: 12px 16px;
  border: 2px solid rgba(144, 202, 249, 0.3);
  border-radius: 8px;
  font-size: 14px;
  transition: all 0.2s ease;
  background: rgba(240, 248, 255, 0.8);
}

#model-select:focus {
  border-color: #1976d2;
  outline: none;
  box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.15);
}

.range-container {
  display: flex;
  align-items: center;
  gap: 15px;
}

#temperature-input {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: rgba(187, 222, 251, 0.5);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
}

#temperature-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1976d2 0%, #42a5f5 100%);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(25, 118, 210, 0.4);
  transition: transform 0.2s ease;
}

#temperature-input::-webkit-slider-thumb:hover {
  transform: scale(1.1);
}

#temperature-value {
  background: #1976d2;
  color: white;
  padding: 6px 12px;
  border-radius: 6px;
  font-weight: bold;
  font-size: 12px;
  min-width: 35px;
  text-align: center;
}

/* Top-p 采样样式 */
#top-p-input {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: rgba(187, 222, 251, 0.5);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
}

#top-p-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #1976d2;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(25, 118, 210, 0.4);
  transition: transform 0.2s ease;
}

#top-p-input::-webkit-slider-thumb:hover {
  transform: scale(1.1);
}

#top-p-value {
  background: #1976d2;
  color: white;
  padding: 6px 12px;
  border-radius: 6px;
  font-weight: bold;
  font-size: 12px;
  min-width: 35px;
  text-align: center;
}

/* 小提示文本样式美化 */
.settings-group small {
  color: #1976d2;
  font-size: 12px;
  margin-top: 8px;
  display: block;
  line-height: 1.4;
  font-style: italic;
  opacity: 0.8;
  transition: opacity 0.2s ease;
}

.settings-group:hover small {
  opacity: 1;
}

/* Ollama 服务地址输入框美化样式 */
#ollama-base-url {
  width: calc(100% - 20px);
  max-width: calc(100% - 20px);
  padding: 16px 20px;
  border: 2px solid rgba(144, 202, 249, 0.3);
  border-radius: 12px;
  font-size: 15px;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  color: #1565c0;
  background: linear-gradient(135deg, #f0f8ff 0%, #e3f2fd 100%);
  box-shadow: 0 2px 8px rgba(25, 118, 210, 0.08);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  box-sizing: border-box;
}

#ollama-base-url::placeholder {
  color: rgba(25, 118, 210, 0.6);
  font-style: italic;
}

#ollama-base-url:focus {
  border-color: #1976d2;
  outline: none;
  box-shadow: 0 0 0 4px rgba(25, 118, 210, 0.15), 0 4px 20px rgba(25, 118, 210, 0.15);
  transform: translateY(-1px);
  background: #ffffff;
}

#ollama-base-url:hover:not(:focus) {
  border-color: #1976d2;
  box-shadow: 0 3px 12px rgba(25, 118, 210, 0.12);
  transform: translateY(-1px);
}

/* 为Ollama服务地址输入框添加图标效果 */
.settings-group:has(#ollama-base-url) {
  position: relative;
  background: linear-gradient(135deg, #f0f8ff 0%, #e3f2fd 100%);
  border: 2px solid rgba(144, 202, 249, 0.3);
  border-radius: 16px;
  box-shadow: 0 4px 16px rgba(25, 118, 210, 0.1);
  transition: all 0.3s ease;
}

.settings-group:has(#ollama-base-url):hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(25, 118, 210, 0.2);
  border-color: #1976d2;
}

.settings-group:has(#ollama-base-url) label {
  background: linear-gradient(135deg, #1976d2 0%, #42a5f5 100%);
  color: white;
  padding: 8px 16px;
  border-radius: 8px;
  margin-bottom: 12px;
  display: inline-block;
  font-size: 13px;
  font-weight: 600;  text-transform: none;
  letter-spacing: 0.3px;
  box-shadow: 0 2px 8px rgba(25, 118, 210, 0.4);
}

/* Top-k 和最大输出长度输入框样式 */
#top-k-input, #max-length-input {
  width: calc(100% - 20px);
  max-width: calc(100% - 20px);
  padding: 12px 16px;
  border: 2px solid rgba(144, 202, 249, 0.3);
  border-radius: 8px;
  font-size: 14px;
  transition: all 0.2s ease;
  background: rgba(240, 248, 255, 0.8);
  box-sizing: border-box;
}

#top-k-input:focus, #max-length-input:focus {
  border-color: #1976d2;
  outline: none;
  box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.15);
}

.button-group {
  display: flex;
  gap: 12px;
  margin-top: 25px;
  padding-top: 20px;
  border-top: 1px solid rgba(144, 202, 249, 0.3);
}

#save-settings-btn {
  flex: 1;
  padding: 14px 24px;
  background: linear-gradient(135deg, #1976d2 0%, #1e88e5 50%, #42a5f5 100%);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  transition: all 0.2s ease;
  box-shadow: 0 3px 12px rgba(25, 118, 210, 0.4);
}

#save-settings-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 20px rgba(25, 118, 210, 0.5);
}

#save-settings-btn:active {
  transform: translateY(0);
}

#refresh-models-btn {
  width: 110px;
  padding: 10px 16px;
  background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
  border: 1px solid rgba(144, 202, 249, 0.5);
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: #1976d2;
  transition: all 0.2s ease;
  white-space: nowrap;
}

#refresh-models-btn:hover {
  background: linear-gradient(135deg, #bbdefb 0%, #90caf9 100%);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(25, 118, 210, 0.2);
}

/* 参数行样式 */
/* 设置部分样式 */
.settings-section {
  margin: 25px 0;
  padding: 20px;
  background: linear-gradient(135deg, #e3f2fd 0%, #f0f8ff 100%);
  border-radius: 15px;
  border: 2px solid rgba(144, 202, 249, 0.3);
  box-shadow: 0 3px 15px rgba(25, 118, 210, 0.1);
}

.settings-section h3 {
  margin: 0 0 20px 0;
  font-size: 18px;
  font-weight: 600;
  color: #1565c0;
  text-align: center;
  padding-bottom: 10px;
  border-bottom: 2px solid rgba(144, 202, 249, 0.3);
}

/* 加载状态样式 */
.loading {
  position: relative;
  overflow: hidden;
}

.loading::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(25, 118, 210, 0.15), transparent);
  animation: loading-shimmer 1.5s infinite;
}

@keyframes loading-shimmer {
  0% { left: -100%; }
  100% { left: 100%; }
}

/* 响应式设计 */
@media (max-width: 768px) {
  .model-content {
    width: 95%;
    margin: 5% auto;
    max-height: 90vh;
  }
    .model-header {
    padding: 16px 20px;
  }
  
  .model-header h2 {
    font-size: 14px;
  }
    .model-body {
    padding: 20px;
    max-height: calc(90vh - 70px);
  }
  
  .model-select-container {
    flex-direction: column;
    gap: 8px;
  }
  
  #model-select {
    width: 100%;
    min-width: auto;
  }
  
  #refresh-models-btn {
    width: 100%;
  }
  
  .range-container {
    flex-direction: row;
    gap: 10px;
  }
  
  .button-group {
    flex-direction: column;
  }
}

/* 暗黑模式支持 */
@media (prefers-color-scheme: dark) {
  .model-content {
    background: linear-gradient(135deg, #1a237e 0%, #303f9f 100%);
    border: 1px solid rgba(144, 202, 249, 0.2);
  }
  
  .settings-section {
    background: linear-gradient(135deg, #283593 0%, #1a237e 100%);
    border-color: rgba(144, 202, 249, 0.3);
  }
  
  .settings-section h3 {
    color: #e3f2fd;
    border-bottom-color: rgba(144, 202, 249, 0.3);
  }
  
  .settings-group {
    background: #283593;
    border: 1px solid rgba(144, 202, 249, 0.3);
  }    .settings-group label {
    color: #e3f2fd;
  }
    #model-select, #max-length-input, #ollama-base-url, #top-k-input {
    background: linear-gradient(135deg, #1a237e 0%, #283593 100%);
    color: #e3f2fd;
    border-color: rgba(144, 202, 249, 0.3);
  }
  
  #ollama-base-url {
    box-shadow: 0 2px 8px rgba(25, 118, 210, 0.3);
  }
  
  #ollama-base-url:focus {
    border-color: #42a5f5;
    box-shadow: 0 0 0 4px rgba(66, 165, 245, 0.25), 0 4px 20px rgba(66, 165, 245, 0.2);
    background: linear-gradient(135deg, #283593 0%, #1a237e 100%);
  }
  
  #ollama-base-url:hover:not(:focus) {
    border-color: #42a5f5;
    box-shadow: 0 3px 12px rgba(25, 118, 210, 0.4);
  }
  
  #ollama-base-url::placeholder {
    color: #90caf9;
  }
  
  .settings-group:has(#ollama-base-url) {
    background: linear-gradient(135deg, #283593 0%, #1a237e 100%);
    border-color: rgba(144, 202, 249, 0.3);
  }
  
  .settings-group:has(#ollama-base-url):hover {
    border-color: #42a5f5;
    box-shadow: 0 8px 32px rgba(66, 165, 245, 0.2);
  }    .settings-group:has(#ollama-base-url) label {
    background: linear-gradient(135deg, #42a5f5 0%, #1976d2 100%);
  }
  
  .settings-group small {
    color: #90caf9;
  }
  
  #temperature-input, #top-p-input {
    background: rgba(144, 202, 249, 0.3);
  }
  
  #refresh-models-btn, #save-settings-btn {
    background: linear-gradient(135deg, #1976d2 0%, #283593 100%);
    color: #e3f2fd;
    border-color: rgba(144, 202, 249, 0.5);
  }
  
  #refresh-models-btn:hover, #save-settings-btn:hover {
    background: linear-gradient(135deg, #283593 0%, #1976d2 100%);
  }
}

/* =================================================================== */
/* 主题切换系统 - 设置模态框 */
/* =================================================================== */

/* 暗色主题 */
body[data-theme="dark"] .model {
  background-color: rgba(0, 0, 0, 0.8);
}

body[data-theme="dark"] .model-content {
  background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 8px 25px rgba(0, 0, 0, 0.3);
}

body[data-theme="dark"] .model-header {
  background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 50%, #404040 100%);
}

body[data-theme="dark"] .model-body {
  background: transparent;
}

body[data-theme="dark"] .settings-section {
  background: linear-gradient(135deg, #2d2d2d 0%, #404040 100%);
  border: 2px solid rgba(255, 255, 255, 0.1);
}

body[data-theme="dark"] .settings-section h3 {
  color: #ffffff;
  border-bottom-color: rgba(255, 255, 255, 0.2);
}

body[data-theme="dark"] .settings-group {
  background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

body[data-theme="dark"] .settings-group label {
  color: #ffffff;
}

body[data-theme="dark"] .settings-group small {
  color: rgba(255, 255, 255, 0.7);
}

body[data-theme="dark"] #model-select,
body[data-theme="dark"] #ollama-base-url,
body[data-theme="dark"] #top-k-input,
body[data-theme="dark"] #max-length-input {
  background: rgba(50, 50, 50, 0.8);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.2);
}

body[data-theme="dark"] #model-select:focus,
body[data-theme="dark"] #ollama-base-url:focus,
body[data-theme="dark"] #top-k-input:focus,
body[data-theme="dark"] #max-length-input:focus {
  background: rgba(60, 60, 60, 0.9);
  border-color: #666;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.1);
}

body[data-theme="dark"] #temperature-input,
body[data-theme="dark"] #top-p-input {
  background: rgba(255, 255, 255, 0.2);
}

body[data-theme="dark"] #temperature-input::-webkit-slider-thumb,
body[data-theme="dark"] #top-p-input::-webkit-slider-thumb {
  background: linear-gradient(135deg, #606060 0%, #808080 100%);
}

body[data-theme="dark"] #temperature-value,
body[data-theme="dark"] #top-p-value {
  background: #606060;
  color: white;
}

body[data-theme="dark"] #save-settings-btn {
  background: linear-gradient(135deg, #404040 0%, #505050 50%, #606060 100%);
  color: white;
}

body[data-theme="dark"] #save-settings-btn:hover {
  background: linear-gradient(135deg, #505050 0%, #606060 50%, #707070 100%);
}

body[data-theme="dark"] #refresh-models-btn {
  background: linear-gradient(135deg, #2d2d2d 0%, #404040 100%);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.2);
}

body[data-theme="dark"] #refresh-models-btn:hover {
  background: linear-gradient(135deg, #404040 0%, #505050 100%);
}

body[data-theme="dark"] .settings-group:has(#ollama-base-url) {
  background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
  border-color: rgba(255, 255, 255, 0.1);
}

body[data-theme="dark"] .settings-group:has(#ollama-base-url) label {
  background: linear-gradient(135deg, #404040 0%, #606060 100%);
  color: white;
}

/* 浅色主题 */
body[data-theme="light"] .model {
  background-color: rgba(0, 0, 0, 0.3);
}

body[data-theme="light"] .model-content {
  background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
  border: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15), 0 8px 25px rgba(0, 0, 0, 0.1);
}

body[data-theme="light"] .model-header {
  background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 50%, #e9ecef 100%);
  color: #333;
}

body[data-theme="light"] .model-header h2 {
  color: #333;
}

body[data-theme="light"] .close {
  color: rgba(0, 0, 0, 0.6);
  background: rgba(0, 0, 0, 0.1);
}

body[data-theme="light"] .close:hover {
  color: #333;
  background: rgba(0, 0, 0, 0.2);
}

body[data-theme="light"] .model-body {
  background: transparent;
}

body[data-theme="light"] .settings-section {
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border: 2px solid rgba(0, 0, 0, 0.1);
}

body[data-theme="light"] .settings-section h3 {
  color: #333;
  border-bottom-color: rgba(0, 0, 0, 0.1);
}

body[data-theme="light"] .settings-group {
  background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
  border: 1px solid rgba(0, 0, 0, 0.1);
}

body[data-theme="light"] .settings-group label {
  color: #333;
}

body[data-theme="light"] .settings-group small {
  color: rgba(0, 0, 0, 0.6);
}

body[data-theme="light"] #model-select,
body[data-theme="light"] #ollama-base-url,
body[data-theme="light"] #top-k-input,
body[data-theme="light"] #max-length-input {
  background: rgba(248, 249, 250, 0.8);
  color: #333;
  border-color: rgba(0, 0, 0, 0.2);
}

body[data-theme="light"] #model-select:focus,
body[data-theme="light"] #ollama-base-url:focus,
body[data-theme="light"] #top-k-input:focus,
body[data-theme="light"] #max-length-input:focus {
  background: rgba(255, 255, 255, 0.95);
  border-color: #666;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.1);
}

body[data-theme="light"] #ollama-base-url::placeholder,
body[data-theme="light"] #top-k-input::placeholder,
body[data-theme="light"] #max-length-input::placeholder {
  color: rgba(0, 0, 0, 0.5);
}

body[data-theme="light"] #temperature-input,
body[data-theme="light"] #top-p-input {
  background: rgba(0, 0, 0, 0.1);
}

body[data-theme="light"] #temperature-input::-webkit-slider-thumb,
body[data-theme="light"] #top-p-input::-webkit-slider-thumb {
  background: linear-gradient(135deg, #dee2e6 0%, #ced4da 100%);
}

body[data-theme="light"] #temperature-value,
body[data-theme="light"] #top-p-value {
  background: #6c757d;
  color: white;
}

body[data-theme="light"] #save-settings-btn {
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 50%, #dee2e6 100%);
  color: #333;
}

body[data-theme="light"] #save-settings-btn:hover {
  background: linear-gradient(135deg, #e9ecef 0%, #dee2e6 50%, #ced4da 100%);
}

body[data-theme="light"] #refresh-models-btn {
  background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
  color: #333;
  border-color: rgba(0, 0, 0, 0.2);
}

body[data-theme="light"] #refresh-models-btn:hover {
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}

body[data-theme="light"] .settings-group:has(#ollama-base-url) {
  background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
  border-color: rgba(0, 0, 0, 0.1);
}

body[data-theme="light"] .settings-group:has(#ollama-base-url) label {
  background: linear-gradient(135deg, #6c757d 0%, #495057 100%);
  color: white;
}
